import { EntitySchema } from '@mikro-orm/core';

export class LeGallery {
  id!: string;
  title!: string;
  type: boolean = true;
  groupId!: string;
  url!: string;
  thumbnail!: string;
  sort: number = 1;
  UID!: string;
  merchantId!: string;
  AppID!: string;
  createdTime!: string;
  updatedTime?: string;
  deletedTime?: string;
  isDeleted: boolean = false;
  size: number = 0;
}

export const LeGallerySchema = new EntitySchema({
  class: LeGallery,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    title: { type: 'string', length: 100 },
    type: { type: 'boolean', default: true },
    groupId: { type: 'string', columnType: 'bigint', defaultRaw: `1`, index: '分组id' },
    url: { type: 'string', length: 255 },
    thumbnail: { type: 'string', length: 255 },
    sort: { type: 'number', columnType: 'smallint', default: 1 },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint' },
    merchantId: { type: 'string', columnType: 'bigint', index: '商户id' },
    AppID: { type: 'string', fieldName: 'AppID', length: 50, index: '应用id' },
    createdTime: { type: 'string', columnType: 'bigint' },
    updatedTime: { type: 'string', columnType: 'bigint', nullable: true },
    deletedTime: { type: 'string', columnType: 'bigint', nullable: true },
    isDeleted: { type: 'boolean', default: false },
    size: { type: 'number', default: 0 },
  },
});
